package thread;

/**
 * NEW->RUNNABLE->TERMINATED
 */
public class ThreadStateNRT {

    public static void main(String[] args) {
        Thread thread = new Thread(new Task());
        ThreadUtils.print(thread.getName(), thread.getState());
        thread.start();
        //等待线程执行完毕。
        try {
            thread.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        ThreadUtils.print(thread.getName(), thread.getState());
    }

    private static class Task implements Runnable {
        @Override
        public void run() {
            ThreadUtils.print(Thread.currentThread().getName(), Thread.currentThread().getState());
        }
    }

}
